<?php

class DB {

	private $connection;
	
	public function connect() {
		$this->connection = new mysqli(DBHOST, DBUSER, DBPWD, DBNAME);
		if (mysqli_connect_errno()) {
			printf("Connect failed: %s\n", mysqli_connect_error());
			exit();
		}
		if ($stmt = $this->connection->prepare("SET NAMES 'utf8'")) {
			$stmt->execute();
			$stmt->close();
		}
		return $this->connection;
	}
	
	public function disconnect() {
		$this->connection->close();
	}

}

?>